﻿using ctolua.Models.Enum;

namespace ctolua.Models.UI.control
{
    public class bar
    {
        /// <summary>
        /// 时间
        /// </summary>
        public double? time { get; set; }
        /// <summary>
        /// 值
        /// </summary>
        public double? value { get; set; }
    }
    public class MCProgress : Mui
    {
        public override EUi type { get => EUi.进度条; set => base.type = EUi.进度条; }


        private bar _current_value;
        /// <summary>
        /// 设置进度条当前值
        /// </summary>
        public bar current_value
        {
            get => _current_value;
            set
            {

                game_api.set_progress_bar_current_value(this.role, this.id, value.value, value.time);
                _current_value = value;
            }
        }

        private double? _max_value;
        /// <summary>
        /// 设置进度条最大值
        /// </summary>
        public double? max_value
        {
            get => _max_value;
            set
            {
                if (value != null)
                {
                    game_api.set_progress_bar_max_value(this.role, this.id, value);
                }

                _max_value = value;
            }
        }

        private string _bind_current_value;
        /// <summary>
        /// 绑定单位属性到玩家界面控件的属性 当前值 为null解绑
        /// </summary>
        public string bind_current_value
        {
            get => _bind_current_value;
            set
            {
                if (value != null)
                {
                    game_api.set_ui_comp_bind_attr(this.role, this.id, "current_value_bind", value, 0);
                }
                else
                {
                    game_api.ui_comp_unbind(this.role, this.id, "current_value_bind");
                }

                _bind_current_value = value;
            }
        }

        private string _bind_max_value;
        /// <summary>
        /// 绑定单位属性到玩家界面控件的属性 最大值
        /// </summary>
        public string bind_max_value
        {
            get => _bind_max_value;
            set
            {
                game_api.set_ui_comp_bind_attr(this.role, this.id, "max_value_bind", value, 0);
                _bind_max_value = value;
            }
        }

        public MCProgress()
        {
        }

        public MCProgress(string id) : base(id)
        {
        }

        public MCProgress(MCProgress u) : base(u)
        {
        }


    }
}
